//
//  YuYueCell.m
//  FD
//
//  Created by Yasin on 2018/10/13.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//  预约cell

#import "YuYueCell.h"
@interface YuYueCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconIv; //头像
@property (weak, nonatomic) IBOutlet UILabel *nameLb;//点名
@property (weak, nonatomic) IBOutlet UILabel *distanceLb;//距离
@property (weak, nonatomic) IBOutlet UILabel *addressLb;//地址
@property (weak, nonatomic) IBOutlet UIButton *yuyueBtn; //立即预约按钮
@property (weak, nonatomic) IBOutlet UIView *topLineView; //上面的线
@property (weak, nonatomic) IBOutlet UIView *bottomLineView; //下面的线

@end
@implementation YuYueCell
- (void)awakeFromNib {
    [super awakeFromNib];
    
    //字段国际化
    NSString *yuyueStr = NSLocalizedString(Home_LiJiYuYue, @"立即预约");
    [self.yuyueBtn setTitle:yuyueStr forState:(UIControlStateNormal)]; //
    [self.yuyueBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    self.addressLb.textColor = kLightGrayTextColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    //根据文字长度计算按钮的长度
//    CGSize btnSize = [yuyueStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17.0]}];
//    CGFloat w = btnSize.width;
//    self.yuyueBtn.rb_width = w;
    
    self.topLineView.backgroundColor = kMainLightGrayColor;
    self.bottomLineView.backgroundColor = kMainLightGrayColor;
}

//设置数据
- (void)setYuyeuModel:(YuYueModel *)yuyeuModel {
    _yuyeuModel = yuyeuModel;
    
    [_iconIv sd_setImageWithURL:[NSURL URLWithString:yuyeuModel.thumbnail]];
    _nameLb.text = yuyeuModel.name;
    _addressLb.text = yuyeuModel.address;
}


#pragma mark  - 点击事件
- (IBAction)clickYuYueBtnAction:(UIButton *)sender {

    if (self.yuyueBtnBlock) {
        self.yuyueBtnBlock();
    }
}

@end
